package com.santoker.baseservice;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class RequestLimitInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 请求地址
        log.info("请求地址为：{}", request.getRequestURI());

        //获取请求参数
        String queryString = request.getQueryString();
        log.info("请求参数:{}", queryString);

        //获取请求body
//        ServletInputStream inputStream = request.getInputStream();
//        byte[] bodyBytes = StreamUtils.copyToByteArray(inputStream);
//        String body = new String(bodyBytes, request.getCharacterEncoding());
//        log.info("请求体：{}", body);

        return true;
    }

}
